<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!--引用CW标签  -->
<%@ taglib uri="/WEB-INF/taglib/cw" prefix="CW"%>
<!--引用struts标签  -->
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<base href="<%=basePath%>">
	<title></title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<%=basePath%>css/en/edit.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="<%=basePath%>js/commons/common_edit.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/commons/common_upload.js"></script>
</head>
<body>
	<jsp:include page="../../common/loadingPage.jsp" />
	<form action="shop/update.action" name="actionForm" id="actionForm" method="post">
		<input name="oldImgView" type="hidden" value="<s:property value="shopInfo.img_view"/>"/>
		<input name="shopInfo.img_view" id="fileFileName" type="hidden" />
		<!-- 页面头 -->
		<div class="pageheader">
			<!-- 操作按钮 -->
			<div class="pageheadercontent">
				<div class="toolbar">
					<div class="toolbarright">
						<input class="okbtn" name="_submit" id="_submit" type="button" value="OK" onclick="__submit()"> 
					</div>
				</div>
			</div>
		</div>
		<!-- 编辑 -->
		<div class="writetblbox">
			<table class="writetbl">
				<tr>
					<th style="width: 25%">名称：</th>
					<td colspan="2"><input name="shopInfo.s_name" type="text" id="s_name" value="<s:property value="shopInfo.s_name" />"></td>
					<td style="width: 25%" rowspan="4">		
						<img style="top: 140px;position: fixed;left:77%;width:100px;height:100px;" alt='' src="<%=path%>/upload/getPriviewInpByPath.action?pathType=1&path=<s:property value="shopInfo.img_view"/>" 
							class="writetblimg" id="imgid"  title="点击上传缩略图">
						<input style="top: 140px;position: fixed;left:77%;width:100px;height:100px;" name="uploadFile" type="file" class="file" 
    						id="uploadFile" accept="image/*" size="28" title="点击上传缩略图" onChange="return _imgUpload('uploadFile','imgid','fileFileName',1048576);"  />
						<div style="top:250px;position: fixed;left:75%;color:red;text-align:center;" >建议上传200*200分辨率</div>
					</td>
				</tr>
				<tr>
					<th>联系方式：</th>
					<td colspan="2"><input name="shopInfo.contact" type="text" value="<s:property value="shopInfo.contact" />"></td>
				</tr>
				<tr>
					<th>地址名称（无需填写省市）：</th>
					<td colspan="2"><input name="shopInfo.position" type="text" value="<s:property value="shopInfo.position" />"></td>
				</tr>
				<tr>
					<td colspan="3"><a href="#" onclick="findtude();return false;" style="text-decoration: none;color:#666">点击访问百度地图获取地址经纬度</a></td>
				</tr>
				<tr>
					<th>经度：</th>
					<td style="width: 25%"><input name="shopInfo.longitude" type="text" value="<s:property value="shopInfo.longitude" />"></td>
					<th style="width: 25%">纬度：</th>
					<td style="width: 25%"><input name="shopInfo.latitude" type="text" value="<s:property value="shopInfo.latitude" />"></td>
				</tr>
			 	<tr>
					<th>商户类型：</th>
					<td colspan="3">
						<input type="hidden" id="stype" name="shopInfo.stype" value="<s:property value="shopInfo.stype" />"/>
					    <s:if test="stypes.size()>0">
        					<s:iterator value="stypes" var="stype" status="status">
								<div style="float:left;margin-left:5px;">
									<input type="checkbox" name="chk_list" id="chk_list_<s:property value="id" />" value="<s:property value="id" />" class="chk_list"/><s:property value="t_name" />
        						</div>
        					</s:iterator>
        				</s:if>
					</td>
				</tr>
				<tr>
					<th>备注：</th>
					<td colspan="3"><input type="text" name="shopInfo.introduction" value="<s:property value="shopInfo.introduction" />"></td>
				</tr>
			</table>
		</div>
	</form>
	<span class="_height"></span>
	<script type="text/javascript">
		/*!
		* 
		* 绑定验证
		* 
		* 注意1：所有的验证规则统一在此处进行定义
		* 注意2：当input中name使用pentity.name这样的命名方式时,其中"."与JQUERY冲突, 则rules: {"pentity.name": {}} 要加上双引号 
		* 
		*/
		$(document).ready(function() {
			$("#radio").buttonset();
			$('#actionForm').validate({
				rules : {
			        "shopInfo.s_name" : {
						required : true,
						maxlength : 64
					},
				    "shopInfo.contact" : {
				    	required : true,
				    	maxlength : 128
					},
					"shopInfo.position" : {
						required : true,
						maxlength: 256
					},
					"shopInfo.longitude" : {
				    	required : true,
				    	number : true,
				    	maxlength : 64
					},
					"shopInfo.latitude" : {
						required : true,
						number : true,
						maxlength: 64
					}
				}
			});
			var stype=$("#stype").val();
			var chk_list = document.getElementsByName('chk_list');
			for(var i=0;i<chk_list.length;i++){
				if(stype.indexOf(chk_list[i].id.replace("chk_list_",""))>=0){
					chk_list[i].checked="checked";
				}
			}
		});
		function _validateName(){
			var result=true;
			$.ajax({  
			    type: "post",  
			    async: false,
			    url: "<%=basePath%>/shopAjax/validateName.action",  
			    data: "s_name=" + $("#s_name").val() ,  
			    success: function(data){
			    	if(data=='fasle'){//重复
					    art.dialog.alert('该名称已经存在，请重新输入');
					    result=false;
			    	}
			    }
			});
			return result;
		}
		//获取被选中的checkbox的值
		function getCheckedValue(){
			var chk_list = document.getElementsByName('chk_list');
			var chkString = "";
			for(var i=0;i<chk_list.length;i++){
				if(chk_list[i].checked){
					 chkString =chk_list[i].value+","+chkString;
				}
			}
			return chkString.substring(0,chkString.length-1);
		}
		function __submit(){
			if($("#actionForm").valid()&&_validateName()){
				var checkedValue=getCheckedValue();
				if(checkedValue==null||checkedValue==""){
					art.dialog.tips('请选择商户分类');
				}else{
					$("#stype").val(checkedValue);
					$("#loadingdiv").show();
					document.actionForm.submit();
				}
			}
		}
		function findtude(){
			window.open("http://api.map.baidu.com/lbsapi/getpoint/index.html");
		}
	</script>
</body>
</html>
